<?php

/**
 * 验证码发送
 * @param $mobile 手机号码
 * @param $content 发送内容
 * @param $type 验证码类型
 */
function send_sms($mobile, $content, $type = '') {
    
}

/**
 * 面包屑导航  用于前台用户中心
 * 根据当前的控制器名称 和 action 方法
 */
function navigate_user() {
    $navigate = include APP_PATH . 'Common/Conf/navigate.php';
    $location = strtolower('Home/' . CONTROLLER_NAME);
    $arr = array(
        '首页' => '/',
        $navigate[$location]['name'] => U('/Home/' . CONTROLLER_NAME),
        $navigate[$location]['action'][ACTION_NAME] => 'javascript:void();',
    );
    return $arr;
}

/**
 *  面包屑导航  用于前台商品
 * @param type $id 商品id  或者是 商品分类id
 * @param type $type 默认0是传递商品分类id  id 也可以传递 商品id type则为1
 */
function navigate_goods($id, $type = 0) {
    $cat_id = $id; //
    // 如果传递过来的是
    if ($type == 1) {
        $cat_id = M('goods')->where("goods_id = $id")->getField('cat_id');
    }
    $categoryList = M('GoodsCategory')->getField("id,name,parent_id");

    // 第一个先装起来
    $arr[$cat_id] = $categoryList[$cat_id]['name'];
    while (true) {
        $cat_id = $categoryList[$cat_id]['parent_id'];
        if ($cat_id > 0)
            $arr[$cat_id] = $categoryList[$cat_id]['name'];
        else
            break;
    }
    $arr = array_reverse($arr, true);
    return $arr;
}

// 计算团队总人数
function jlsja($var) {
    $ids = get_num($var);
    if (!$ids) {
        return $trees;
    }
    foreach ($ids as $v) {
        $_SESSION['tuan_dui'] ++;
        jlsja($v);
    }
}

function get_num($id) {
    if (!$id)
        return null;
    $childs_id = array();
    $childs = M("users")->field("user_id")->where(array('first_leader' => $id))->select();
    foreach ($childs as $v) {
        $childs_id [] = $v ['user_id'];
    }

    if ($childs_id)
        return $childs_id;
    return 0;
}